import Vue from 'vue'
import VueRouter from 'vue-router'
import login from "@/views/login/login.vue";
import error from "@/components/error_404.vue";
import index from "@/views/index/index.vue";


Vue.use(VueRouter)

const routes = [{
        path: '/',
        redirect: '/index'
    },
    {
        path: '/index',
        component: index
    },
    {
        path: '/login',
        component: login
    },
    {
        path: '/error',
        name: 'error',
        component: error
    },
    {
        path: '*',
        component: () =>
            import ('@/components/error_404.vue')
    }
]

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
    // mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router